package com.queue;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * @Author: linKe
 * @Date: 2022/1/2 1:06
 * @FileName: LinkedQueueTest
 * @version: 1.0
 * @Description: 链式队列的测试类
 */
public class LinkedQueueTest {

    private LinkedQueue<Integer> queue;
    @Before
    public void setUp() throws Exception {
        queue= new LinkedQueue<>();
        queue.add(1);
        queue.add(2);
        queue.add(3);
        queue.add(4);

    }

    @Test
    public void isEmpty() {
        boolean empty = queue.isEmpty();
        System.out.println(empty);
        //false
    }

    @Test
    public void add() {
        boolean add = queue.add(5);
        System.out.println(add);
        //false 这里不应该是false呀
        //true  add（）方法最后返回的结果写错了
        System.out.println(queue.toString());
        //com.queue.LinkedQueue(1,2,3,4,5)
    }

    @Test
    public void peek() {
        Integer peek = queue.peek();
        System.out.println(peek);
        //1
    }

    @Test
    public void poll() {
        Integer poll = queue.poll();
        System.out.println(poll);
        //1 这里获取的是删除之前的头结点的元素
    }

    @Test
    public void testToString() {
        System.out.println(queue.toString());
        //com.queue.LinkedQueue(1,2)
    }
}